﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="newsadd.aspx.cs" Inherits="new_add"  validateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery-ui-1.7.3.custom.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="../edit/jquery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="../edit/xheditor-zh-cn.src.js"></script>
    <script src="../js/jquery.autocomplete.js"  type="text/javascript" language="javascript" ></script>
    <script src="../js/StockSearchData.js" language="javascript" type="text/javascript"></script>
    <script src="../js/jquery-ui-1.7.3.custom.min.js" language="javascript" type="text/javascript"></script>
     <script type="text/javascript" defer="defer" src="../My97DatePicker/WdatePicker.js"></script>
     
    <script type="text/javascript" language="javascript">
        var selectValue = new Array();
        $(pageInit);
        function pageInit() {
            $('#txtSummary,').xheditor();
            $("#txtContent").xheditor({ upImgUrl: "../upload/newsUpload.aspx", upImgExt: "jpg,jpeg,gif,png" })
        }
        function insertUpload(msg) {
            msg = msg[0];
            $("#uploadList").append('<option value="' + msg.id + '">' + msg.localname + '</option>');
        }
        function submitForm() { $('#frmDemo').submit(); }
        $(document).ready(function () {
            $("#btnBack,#btnBack1").click(function () {
                document.location = "news.aspx";
            })
            $('#dialog').dialog({
                autoOpen: false,
                modal: true,
                width: 600,
                buttons: {
                    "取消": function () {
                        var chks = $("#DataList1 input[type=checkbox]");
                        for (var i = 0; i < chks.length; i++) {
                            chks[i].checked = false;
                            for (var j = 0; j < selectValue.length; j++) {
                                if (chks[i].value == selectValue[j]) {
                                    chks[i].checked = true;
                                }
                            }
                        }
                        $(this).dialog("close");
                    },
                    "确定": function () {
                        var chks = $("#DataList1 input[type=checkbox]");
                        $("#lblSelectType").html('');
                        var txt = '';
                        var val = "";
                        for (var i = 0; i < chks.length; i++) {
                            var chk = chks[i]
                            if (chk.checked) {
                                txt += $(chk).parent().children("label").html() + ",";
                                val += $(chk).val() + ",";
                            }
                        }
                        if (txt.length == 0) {
                            alert("必须选择一个新闻类型");
                            return;
                        }
                        if (val.length > 0) {
                            val = val.substring(0, val.length - 1);
                            $("#hidSelectValue").val(val);
                        }
                        if (txt.length > 0) {
                            txt = txt.substring(0, txt.length - 1);
                        }
                        $("#lblSelectType").html(txt);
                        $(this).dialog("close");
                    }
                }
            });
            $("#btnSelect").click(function () {
                var chks = $("#DataList1 input[type=checkbox]");

                var vals = $("#hidSelectValue").val().split(",");
                for (var i = 0; i < vals.length; i++) {
                    for (var j = 0; j < chks.length; j++) {
                        if (chks[j].value == vals[i]) {
                            chks[j].checked = true;
                        }
                    }
                }
                selectValue.length = 0;
                for (var i = 0; i < chks.length; i++) {
                    if (chks[i].checked) {
                        selectValue[selectValue.length] = $(chks[i]).val();
                    }
                }
                $('#dialog').dialog('open');
            })
        })

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hidSelectValue" runat="server" />
    <div class="button_bar">
	    <input type="button" class="common_button" id ="btnBack" value="返回"  />
        <asp:Button ID="btnSave" CssClass="common_button" runat="server" Text="保存" 
            onclick="btnSave_Click"   />
    </div>
    <div>
    <table class="query_form_table">
        <tr>
            <th>新闻类型</th>
            <td colspan="3">
                <asp:DropDownList ID="ddlType" runat="server">
                </asp:DropDownList>
            </td>
        </tr>
      <tr>
            <th>
                标题
            </th>
            <td colspan="3">
                <asp:TextBox ID="txtTitle" runat="server" Width="465px" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ControlToValidate="txtTitle" Display="Dynamic" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
            </td>
        </tr>
	    <tr>
            <th>
                新闻编号
            </th>
            <td>
                自动
            </td>
             <th>
                机构</th>
            <td><asp:TextBox ID="txtSource" runat="server" /> </td>
        </tr>
        <tr>
           <th>作者</th>
           <td>
                <asp:TextBox ID="txtAuthor" runat="server" />
           </td>
           <th>
                相关股票
           </th>
           <td>
              <asp:TextBox ID="txtStock" runat="server" MaxLength="6" />
           </td>
        </tr>
        <tr>
            <th>关键字</th>
            <td colspan="3" >
                <asp:TextBox ID="txtKeyWords" runat="server" Width="382px" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txtKeyWords" Display="Dynamic" ErrorMessage="*" 
                    ForeColor="Red"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <th>图片</th>
            <td colspan="3">
                  <asp:Image ID="Image1" runat="server"  />
                  <asp:FileUpload ID="FileUpload1" runat="server" />
                  <asp:Button ID="Button3" runat="server" CausesValidation="False" 
                      onclick="Button3_Click" Text="上传" />
            </td>
        </tr>
        <tr>
            <th>摘要</th>
            <td colspan="3">
                 <asp:TextBox ID="txtSummary" runat="server" Width="80%" Height="113px" TextMode="MultiLine" />
            </td>
        </tr>     
        <tr>
            <th>内容</th>
            <td colspan="3">
                 <asp:TextBox ID="txtContent" runat="server" Width="80%" Height="300px" TextMode="MultiLine" />
            </td>
        </tr>
    </table>
    </div>
     <div class="button_bar">
	    <input type="button" class="common_button" id ="btnBack1" value="返回" />
        <asp:Button ID="Button2" CssClass="common_button" runat="server" Text="保存" 
            onclick="btnSave_Click"   />
    </div>
    </form>
</body>
</html>


